package com.engr.springbooteasypoi.thread;

public class ThreadResult extends Thread {

    ThreadB threadB;

    public ThreadResult(ThreadB threadB) {
        this.threadB = threadB;
    }

    @Override
    public void run() {
        synchronized (threadB){
            System.out.println("等待计算结果....");
            try {
                threadB.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread() + " 计算结果为：" + threadB.total);
        }
    }

    public static void main(String[] args) {
        ThreadB threadB = new ThreadB();
        new ThreadResult(threadB).start();
        threadB.start();
        System.out.println("Thread-> " + Thread.currentThread());
    }
}
